#include <QCoreApplication>
#include <QDBusConnection>
#include "demoobject.h"
#include "test_adaptor.h"
#include <QDebug>
#include <iostream>

const QString DaemonServicePath = "com.bobbi.demo";

int main(int argc, char **argv)
{
    QCoreApplication a(argc, argv);
    DemoObject *demo = new DemoObject();
    new DbusAdaptor(demo);
    QDBusConnection connection = QDBusConnection::sessionBus();
    if (!connection.registerService(DaemonServicePath)) {
        qDebug() << "registerService false, " << connection.lastError().message();
        return 1;
    }
    if (!connection.registerObject("/com/bobbi/demo", demo)) {
        qDebug() << "registerObject false, " << connection.lastError().message();
        return 1;
    }


    QTimer::singleShot(10000, demo, [&](){
       std::cout << "now will send  12, 13" << std::endl;
       demo->send_send_add_request(12, 13);
    });

    return a.exec();
}
